﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RayTracing
{
    class NonReflective : Skin
    {

        public NonReflective()
        {
        }

        #region Skin Members

        public Color color(P3 point, Ray ray, SceneObject sceneObject) //Returns the color of the non-reflective skin on the object
        {
            // gets the color of the texture at the point on the surface of the SceneObject.
            P2 textureLocation = sceneObject.geometry.toP2(point);
            Color textureColor = sceneObject.texture.textureAt(textureLocation);

            Color sumOfLights = Color.BLACK;
            Color lightColor;

            //sets the lightColor then adds the sumOfLights to the lightColor
            foreach (Light lightSource in Main.lightSources)
            {
                lightColor = lightSource.illumination(point,sceneObject );
                sumOfLights = Color.add(sumOfLights, lightColor);
            }
            
            return Color.mul(textureColor, sumOfLights);
            
        }

        #endregion
    }
}
